-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(builder): use find-cache-dir to support customizing cache directory location #196
feat(builder): use find-cache-dir to support customizing cache directory location #196
Conversation
✅ Deploy Preview for storybook-rsbuild canceled.
|
Thank you! |
Thank you. Generally LGTM, I'm wondering do we need to document this out, but I found it's also not documented in Storybook's site. |
@fi3ework Thank you for checking this so quickly; let me know if there are any further changes you'd like to see for the contribution. I couldn't find the cache dir env variable documented on the main Storybook configuration either besides the Github issues and the Vite builder source code such as here: https://github.com/storybookjs/storybook/blob/abe4c8813017be23b96b3a4faee11344bd2d6163/code/builders/builder-vite/src/plugins/external-globals-plugin.ts#L55 |
? // TODO: This is a hard code cache dir, as Rspack doesn't support virtual modules now. | ||
// Remove this when Rspack supports virtual modules. | ||
(findCacheDirectory({ | ||
name: 'storybook-rsbuild-builder', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it on purpose to change the cache dir from .cache/storybook/storybook-rsbuild-builder
to .cache/storybook-rsbuild-builder
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fi3ework I was wondering the same thing, but apparently a separate directory under .cache is consistent with sb-vite and the other libraries using findCacheDir:
I did find storybook internally using findCacheDir
to create the top-level one and then a custom cache directory system beneath it:
- https://github.com/storybookjs/storybook/blob/3d2eaaf5cbce0dce6aac292d671d0048ac137e35/code/core/src/common/utils/resolve-path-in-sb-cache.ts#L14
- https://github.com/storybookjs/storybook/blob/3d2eaaf5cbce0dce6aac292d671d0048ac137e35/code/core/src/common/utils/cache.ts#L4
- https://github.com/storybookjs/storybook/blob/3d2eaaf5cbce0dce6aac292d671d0048ac137e35/code/core/src/common/utils/file-cache.ts#L158
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine to place it in either location. I can't recall why I initially put it inside ./storybook
—maybe it was just an unconscious choice. I'm glad to see we're now aligned with Storybook. Thank you.
Since the solution could be found in Storybook, I think we don't need to add documentation for now. |
Add support for customizing the cache directory using the
CACHE_DIR
environment variable via https://www.npmjs.com/package/find-cache-dir.Resolves: #197